﻿<!DOCTYPE html>
@{
    if (false)
    {
        <script src="~/LiberUI/Scripts/jquery.js"></script>
        <script src="~/LiberUI/jquery-vsdoc.js"></script>
        <script src="~/LiberUI/Scripts/LiberUI.Base.js"></script>
        <script src="~/LiberUI/Scripts/LiberUI.Action.js"></script>
        <script src="~/LiberUI/Scripts/LiberUI.js"></script>
    }
}
<html>
<head>
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0" />
    <title>我的天联云</title>
    <link href="/SiteUI/Base.css" rel="stylesheet" />
    <link href="/LiberUI/Style/LiberUI.css" rel="stylesheet" />
    <link href="/SiteUI/Wechat/wechatBinding.css" rel="stylesheet" />
</head>
<body>
    <div class="view">
        <div class="row">
            <div id="userHead-bg">
                <img id="headPortrait" src="/SiteUI/Imgs/logo-txt-little.png">
                <h3 id="userName"></h3>
            </div>
        </div>
            <div class="row details">
                <div class="col-lg-4">实名认证：</div>
                <div class="col-lg-4" id="realNameStatus">未认证</div>
                <span class="col-lg-4"><a id="realNameStatusLink" href="/WxPages/WxAcntCertify.html">申请认证</a></span>
            </div>
            <div class="row details">
                <div class="col-lg-4">手机号码：</div>
                <div class="col-lg-8" id="userPhone">-</div>
            </div>
            <div class="row details">
                <div class="col-lg-4">微信号：</div>
                <div class="col-lg-4" id="wechatState">你还未微信绑定</div>
                <span class="col-lg-4"><a id="wechatBind" href="#"></a></span>
            </div>
            <div class="row details">
                <div class="col-lg-4">我的企业：</div>
                <span class="col-lg-8"><a href="/WxPages/WxSetCompany.html">创建企业/加入企业</a></span>
            </div>
            <div id="myCompanys">  
              
                </div>

        <div id="CancelPopup">
            取消绑定后你将无法使用微信快捷方便的完成业务操作
        </div>
    </div>

    <script src="/LiberUI/Scripts/jquery.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.Base.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.Action.js"></script>
    <script src="/LiberUI/Scripts/laytpl.js"></script>
    <script id="MyCompany" type="text/html">
        <div class="row WxCompanyCard">
            <img src="{{d.logourl}}" />
            <div class="col-lg-9" style="margin-top:1rem">
                {{d.name}}<br />{{(d.division)?d.division:' '}}
            </div>
            <div class="col-lg-3" style="line-height:6rem;">
                {{(d.code)?d.code:' '}}
            </div>
        </div>

        </script>
        <script>
            Index = {
                User: null,
                Popup: null,
                GetUserInfo: function (rtn) {
                    if (rtn.IsPositive) {
                        User = rtn.Data;
                        if (!User.wxuser) {
                            window.location = "/WxPages/WxRegister.html?tm=" + new Date().toString();
                        }
                        $("#headPortrait").attr("src", User.headimg);
                        $("#userPhone").vl(User.acnt);
                        $("#userName").vl(User.username);
                        switch (User.certifystatus) {
                            case "Pending": //审核中
                                $("#realNameStatus").vl("审核中");
                                $("#realNameStatusLink").remove();
                                break;
                            case "Aborted": //审核不通过
                                $("#realNameStatus").vl("未通过");
                                break;
                            case "Completed":  //审核通过
                                $(".People").removeClass("no-certificated").addClass("certificated");
                                $("#realNameStatus").vl("已认证");
                                $("#realNameStatusLink").remove();
                                break;
                        }

                        //获取与我有关的公司信息
                        $.getJSON("/MyBiz/GetMyExCompanies", {}, Index.companyCard);
                    }
                    else {
                        window.location = "/WxPages/WxRegister.html?tm=" + new Date().getTime().toString();
                    }
                },
                companyCard: function (rtn) {
                    if (rtn.IsPositive) {
                        Index.MyCompany = rtn.Data;
                        var obj = {
                            name: null,
                            division: null,
                            logourl: null,
                            code: null
                        };
                        //认证公司
                        for (var i = 0; i < User.Orgs.length; i++) {
                            obj.name = User.Orgs[i].name;
                            obj.logourl = User.Orgs[i].logourl;
                            obj.division = "岗位";
                            if (i == 0) {
                                obj.code = " <div class='button disabled '>已为企业名片</div>";
                            } else {
                                obj.code = " <div class='button '>设为企业名片</div>";
                            }
                            var q = Index.tplDlvItem.render(obj);
                            $("#myCompanys").append(q);
                        }
                        for (var i = 0; i < Index.MyCompany.created.length; i++) {
                            obj.name = Index.MyCompany.created[i].name;
                            obj.logourl = Index.MyCompany.created[i].logourl;
                            if (Index.MyCompany.created[i].status == "Pending") {
                                obj.division = "认证申请中";
                                obj.code = null;
                            } else {
                                obj.division = "认证审核结果:不通过<br/>原因:" + Index.MyCompany.created[i].feedback;
                                obj.code = " <div class='button '>重新申请认证</div>";
                            }
                            var q = Index.tplDlvItem.render(obj);
                            $("#myCompanys").append(q);
                        }
                        for (var i = 0; i < Index.MyCompany.applied.length; i++) {
                            obj.name = Index.MyCompany.applied[i].name;
                            obj.logourl = Index.MyCompany.applied[i].logourl;
                            if (Index.MyCompany.applied[i].status == "Pending") {
                                obj.division = "认证申请中";
                                obj.code = "<div class='button '>取消申请</div>";
                            } else {
                                obj.division = "认证审核结果:不通过<br/>原因:" + Index.MyCompany.applied[i].feedback;
                                obj.code = " <div class='button '>重新申请认证</div>";
                            }
                            var q = Index.tplDlvItem.render(obj);
                            $("#myCompanys").append(q);
                        }
                    }
                },
                wechatCard: function () {
                    if (!User.wxuser) {
                        //无绑定
                        $("#wechatState").vl("还未绑定微信");
                    }
                    else {
                        //有绑定
                        $("#wechatState").vl(User.wxname);
                        $("#wechatBind").vl("解除绑定");
                        $("#wechatBind").on("click", function () {
                            //解除微信绑定
                            Index.Popup.update().show();
                        });
                    }
                },
                wechatUnbind: function () {
                    $.getJSON("/MyBiz/UnbindWechat", null, function () {
                     //   Index.Popup.hide();
                       // window.location = "/MyBiz/WxIndex?tm=" + new Date().getTime().toString();
                    });
                }
            }

            $(function () {
             //   $.getJSON("/MyBiz/GetUserInfo", { tm: new Date().getTime().toString() }, Index.GetUserInfo);
               // $.getJSON("/MyBiz/GetMyExCompanies", null, Index.companyCard)
                Index.Popup = new LiberUI.Dialoger()
                                         .Title("取消绑定")
                                         .Content($("#CancelPopup"))
                                         .BtnEnter("确定", "", Index.wechatUnbind)
                                         .BtnEsc("取消", "");
                Index.tplDlvItem = laytpl($("#MyCompany")[0].innerHTML);
            })

        </script>
</body>

</html>
